package com.tanhua.dubbo.api;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.tanhua.dubbo.mappers.NairTopicMapper;
import com.tanhua.model.db.NairTopic;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.ArrayList;
import java.util.List;
@DubboService
public class NairTopicApiImpl implements NairTopicApi{
    @Autowired
    private NairTopicMapper nairTopicMapper;
    @Override
    public List<Long> findByNairId(Integer nair_id) {
        QueryWrapper qw = new QueryWrapper();
        qw.eq("nair_id",nair_id);
        List<NairTopic>  list = nairTopicMapper.selectList(qw);
        List<Long> ids = new ArrayList<>();
        for (NairTopic nairTopic : list) {
            ids.add(Long.valueOf(nairTopic.getQuestionId()));
        }
        return ids;
    }

    @Override
    public Integer findIdByTopic(String questionId) {
        QueryWrapper qw = new QueryWrapper();
        qw.eq("question_id",questionId);
        NairTopic nairTopic = nairTopicMapper.selectOne(qw);
        return nairTopic.getNairId();
    }
}
